<template>
  <div>
    <el-table
      :data="tableData"
      style="width: 100%; margin-bottom: 20px"
      row-key="id"
      border
      :cell-style="cellStyle"
      default-expand-all
      :tree-props="{ children: 'children' }"
    >
      <el-table-column type="selection" align="center" width="55" />
      <el-table-column prop="date" label="日期" sortable width="180"> </el-table-column>
      <el-table-column prop="name" label="姓名" sortable width="180"> </el-table-column>
      <el-table-column prop="one" label="1" width="80"> </el-table-column>
      <el-table-column prop="two" label="2" width="80"> </el-table-column>
      <el-table-column prop="three" label="3" width="80"> </el-table-column>
      <el-table-column prop="four" label="4" width="80"> </el-table-column>
      <el-table-column prop="address" label="地址"> </el-table-column>
    </el-table>
    <el-select v-model="value" placeholder="请选择">
    <el-option
      v-for="item in options"
      :key="item.value"
      :label="item.label"
      :value="item.value">
    </el-option>
  </el-select>
  <selectTree :options="tableData1"></selectTree>

  </div>
</template>
<script>
import selectTree from '../components/selectTree'
export default {
  components: {
    selectTree
  },
  data () {
    return {
      options: [{
        value: '选项1',
        label: '黄金糕'
      }, {
        value: '选项2',
        label: '双皮奶'
      }, {
        value: '选项3',
        label: '蚵仔煎'
      }, {
        value: '选项4',
        label: '龙须面'
      }, {
        value: '选项5',
        label: '北京烤鸭'
      }],
      value: '',
      tableData: [
        {
          date: 'xxxxxx项目'
        },
        {
          id: 4,
          date: '2017-05-01',
          name: '王虎',
          address: '上海市普陀区金沙江路00000 弄'
        },
        {
          id: 4,
          date: '2017-05-01',
          name: '王虎',
          address: '上海市普陀区金沙江路00000 弄'
        }
      ],
      tableData1: [
        {
          id: 3,
          date: '2016-05-01',
          name: '王小虎1',
          address: '上海市普陀区金沙江路 1519 弄'
        },
        {
          id: 3,
          date: '2016-05-01',
          name: '王小虎2',
          address: '上海市普陀区金沙江路 1519 弄'
        },
        {
          id: 3,
          date: '2016-05-01',
          name: '王小虎3',
          address: '上海市普陀区金沙江路 1519 弄',
          children: [
            {
              id: 31,
              date: '2016-05-01',
              name: '王小虎4',
              address: '上海市普陀区金沙江路 1519 弄',
              children: [
                {
                  id: 31,
                  date: '2016-05-01',
                  name: '王小虎',
                  address: '上海市普陀区金沙江路 1519 弄',
                  children: []
                },
                {
                  id: 32,
                  date: '2016-05-01',
                  name: '王小虎5',
                  address: '上海市普陀区金沙江路 1519 弄'
                }
              ]
            },
            {
              id: 32,
              date: '2016-05-01',
              name: '王小虎',
              address: '上海市普陀区金沙江路 1519 弄'
            },
            {
              id: 3,
              date: '2016-05-01',
              name: '王小虎',
              address: '上海市普陀区金沙江路 1519 弄'
            },
            {
              id: 3,
              date: '2016-05-01',
              name: '王小虎',
              address: '上海市普陀区金沙江路 1519 弄'
            },
            {
              id: 3,
              date: '2016-05-01',
              name: '王小虎22',
              address: '上海市普陀区金沙江路 1519 弄'
            },
            {
              id: 3,
              date: '2016-05-01',
              name: '王小虎33',
              address: '上海市普陀区金沙江路 1519 弄'
            },
            {
              id: 3,
              date: '2016-05-01',
              name: '王小虎123',
              address: '上海市普陀区金沙江路 1519 弄'
            },
            {
              id: 3,
              date: '2016-05-01',
              name: '王小虎3123',
              address: '上海市普陀区金沙江路 1519 弄'
            },
            {
              id: 3,
              date: '2016-05-01',
              name: '王小虎',
              address: '上海市普陀区金沙江路 1519 弄'
            },
            {
              id: 3,
              date: '2016-05-01',
              name: '王小虎22',
              address: '上海市普陀区金沙江路 1519 弄'
            },
            {
              id: 3,
              date: '2016-05-01',
              name: '王小虎33',
              address: '上海市普陀区金沙江路 1519 弄'
            },
            {
              id: 3,
              date: '2016-05-01',
              name: '王小虎123',
              address: '上海市普陀区金沙江路 1519 弄'
            }
          ]
        }
      ]
    }
  },
  methods: {
    cellStyle ({ row, column, rowIndex, columnIndex }) {
      console.log('22', row, column, rowIndex, columnIndex)
      if (rowIndex === 0) {
        return 'backgroundColor: #5B9BD5'
      }
      if (rowIndex === 1 && [3, 4].includes(columnIndex)) {
        return 'backgroundColor:yellow'
      }
    },
    load (tree, treeNode, resolve) {
      setTimeout(() => {
        resolve([
          {
            id: 31,
            date: '2016-05-01',
            name: '王小虎',
            address: '上海市普陀区金沙江路 1519 弄'
          },
          {
            id: 32,
            date: '2016-05-01',
            name: '王小虎',
            address: '上海市普陀区金沙江路 1519 弄'
          }
        ])
      }, 1000)
    }
  }
}
</script>
